<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title><?php echo ($title); ?></title>
    <link rel="stylesheet" href="/Public/web/css/pintuer.css">
    <link rel="stylesheet" href="/Public/web/css/admin.css">
    <script src="/Public/web/js/jquery.js"></script>
    <script src="/Public/web/js/pintuer.js"></script>
</head>

<script src="/Public/layer/layer.js"></script>
<body>
  <div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> <?php echo L("canzhuoliebiao");?></strong></div>
    <div class="padding border-bottom">
      <a class="button border-main icon-plus-square-o" href="<?php echo U('Table/addTable');?>"> <?php echo L("tianjia");?></a>
    </div>
    <table class="table table-hover text-center">
      <tr>
        <th width="10%"><?php echo L("canzhuohao");?></th>
        <th width="20%"><?php echo L("canzhuoleixing");?></th>
        <th width="20%"><?php echo L("canzhuozhuangtai");?></th>
        <th width="10%"><?php echo L("caozuo");?></th>
      </tr>
      <?php if(is_array($info)): foreach($info as $key=>$v): ?><tr class="o<?php echo ($v['id']); ?>">
          <td><?php echo ($v['table_num']); ?></td>
          <td><?php echo ($v['table_cate_name']); ?></td>
          <td>
            <span class="sp01" onclick="is_show(<?php echo ($v['id']); ?>,this)">
            <?php if($v['table_status'] == 0): ?><img src="/Public/web/images/no.png" width="18px;" >
              <?php else: ?>
              <img src="/Public/web/images/yes.png" width="18px;" ><?php endif; ?>
            </span>
          </td>
          <td>
            <div class="button-group">
              <a class="button border-main" href="javascript:void(0)" onclick="showHTML(<?php echo ($v['table_num']); ?>)"><span class="icon-edit"></span> <?php echo L("shengchengerweima");?>
              </a>
            </div>
              <div class="button-group ">
                <a class="button border-main" href="javascript:void(0)" onclick="return del(<?php echo ($v['id']); ?>)"><span class="icon-edit"></span> <?php echo L("shanchu");?></a>
              </div>
          </td>
        </tr><?php endforeach; endif; ?>
      <tr>
        <td colspan="10">
          <div class="pagelist"><?php echo ($show); ?></div>
        </td>
      </tr>
    </table>
  </div>

  <script type="text/javascript">
    function del(id){
      if(confirm("<?php echo L('shanchuxiaoxi');?>")){
        var url = "<?php echo U('Table/delete');?>";
        $.getJSON(url,{id:id},function (data){
          if(data.result == 'tp1'){$('.o'+id).remove();}
          else if(data.result == 'break'){alert('ERROR.');}
        })
      }
    }

    function is_show(id,t){
      var url = "<?php echo U('Table/is_show');?>";
      $.getJSON(url,{id:id},function (data){
        if(data.result == 'yes'){
          $(t).find('img').attr('src',"/Public/web/images/yes.png");
        }else if(data.result == 'no'){
          $(t).find('img').attr('src',"/Public/web/images/no.png");
        }
      })
    }

       function showHTML(table_num){
         console.log(table_num);
         layer.open({
           type: 2,
           title: false,
           closeBtn: 1, //不显示关闭按钮
           shade: [0],
           area: ['300px', '300px'],
           offset: 'center', //右下角弹出
          // time: 2000, //2秒后自动关闭
           anim: 3,
           content:["<?php echo U('Table/qrcode');?>?id="+table_num, 'no'], //iframe的url，no代表不显示滚动条
         });
       }
  </script>
</body>

</html>